package com.yunji.news.util;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

public class PasswordGenerator {
    public static void main(String[] args) {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        String password = "admin123";
        String hashedPassword = encoder.encode(password);
        
        System.out.println("Original password: " + password);
        System.out.println("Hashed password: " + hashedPassword);
        
        // 验证
        boolean matches = encoder.matches(password, hashedPassword);
        System.out.println("Verification: " + matches);
        
        // 测试现有的哈希值
        String existingHash = "$2a$10$7JB720yubVSOfvVWdqBPy.lqn9GdHPl4qlWPUJPyVzHEUL8eYjzjy";
        boolean matchesExisting = encoder.matches(password, existingHash);
        System.out.println("Existing hash matches: " + matchesExisting);
    }
}